#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "

insert into hive.edu_dwb.dwb_signin_detail
select
       s.class_id,
       s.student_id,
       substring(s.signin_time,12,8) as signin_time,
       s.signin_date,
       sc.studying_student_count,
       cout.content,
       ct.morning_begin_time,
       ct.morning_end_time,
       ct.afternoon_begin_time,
       ct.afternoon_end_time,
       ct.evening_begin_time,
       ct.evening_end_time,
       ct.use_begin_date,
       ct.use_end_date
from hive.edu_dwd.ft_teach_tbh_student_signin_record s
left join hive.edu_dwd.dt_teach_class_studying_student_count sc on s.class_id = sc.class_id and s.signin_date = sc.studying_date
left join hive.edu_dwd.dt_teach_course_table_upload_detail cout on s.class_id = cout.class_id and s.signin_date = cout.class_date
left join hive.edu_dwd.dt_teach_tbh_class_time_table ct on s.class_id = ct.class_id and s.signin_date between ct.use_begin_date and ct.use_end_date
where content is not null;

insert into hive.edu_dwb.dwb_leave_detail
select
       la.class_id,
       la.student_id,
       la.audit_state,
       la.leave_type,
       la.begin_time,
       la.begin_time_type,
       la.end_time,
       la.end_time_type,
       la.days as leave_days,
       la.valid_state,
       ct.morning_begin_time,
       ct.morning_end_time,
       ct.afternoon_begin_time,
       ct.afternoon_end_time,
       ct.evening_begin_time,
       ct.evening_end_time,
       ct.use_begin_date,
       ct.use_end_date
from hive.edu_dwd.ft_teach_student_leave_apply la
left join hive.edu_dwd.dt_teach_tbh_class_time_table ct on la.class_id = ct.class_id
left join hive.edu_dwd.dt_teach_course_table_upload_detail cout on la.class_id = cout.class_id
where content is not null;

"